<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
           <a-row :gutter="24">

         <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="品类">
               <a-select
                  v-model="queryParam.category"
                 style="width: 150px"
                @focus="focus"
                ref="select"
                @change="handleChange"
                placeholder="请选择品类"
              >
                 <a-select-option v-for="item in categoryList"  :key="item.id" >
                      {{item.category_name}}
                      </a-select-option>
            </a-select>
            </a-form-item>
          </a-col>

             <a-col :xl="6" :lg="7" :md="8" :sm="24">
   <a-form-item label="业务类型" style="margin-left: -20px">
    <a-select
    v-model="queryParam.businessType"
      style="width: 150px"
      @focus="focus"
      ref="select"
      @change="handleChange"
       placeholder="请选择业务类型"
    >
      <a-select-option value="0">
        个定定制
      </a-select-option>
      <a-select-option value="1">
        团体定制
      </a-select-option>
      <a-select-option value="2" >
         标码加工
      </a-select-option>
    </a-select>
    </a-form-item>
     </a-col>

             <a-col :xl="5" :lg="7" :md="8" :sm="24">
               <a-form-item label="状态">
               <a-select v-model="queryParam.queryStatus" ref="select" placeholder="请选择状态">
                 <a-select-option value="0">未设置</a-select-option>
                 <a-select-option value="1">已设置</a-select-option>
               </a-select>
               </a-form-item>
             </a-col>

          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">刷新</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- table区域-begin -->
    <div>
<!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
<!--        <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{-->
<!--        selectedRowKeys.length }}</a>项&nbsp;&nbsp;-->
<!--        <a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
<!--      </div>-->

      <a-table
        ref="table"
        bordered

        size="middle"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <template slot="avatarslot" slot-scope="text, record, index">
          <div class="anty-img-wrap">
            <a-avatar shape="square" :src="getAvatarView(record.avatar)" icon="user"/>
          </div>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="seeLadderPriceSetting(record)" v-if="record.status==0">设置阶梯售价</a>
 <a @click="seeLadderPriceSetting(record)" v-if="record.status==1">查看阶梯售价</a>
        </span>


      </a-table>
    </div>
    <!-- table区域-end -->
  </a-card>
</template>

<script>
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import JInput from '@/components/jeecg/JInput'
  import {getAction} from "../../api/manage";
  import Qs from 'qs'

  export default {

    mixins: [JeecgListMixin],
    components: {
      JInput,
    },
    data() {
      return {
          categoryList:{ //用来存放取到的品类

        },
        description: '这是新增装箱单',
        boxName: '', // 装箱单名称
        remark: '', // 备注
        queryParam: {},
        recycleBinVisible: false,
        productList: [], // 产品列表
        columns: [
          // {
          //   title: '序号',
          //   dataIndex: '',
          //   key: 'rowIndex',
          //   width: 60,
          //   sorter: true,
          //   align: "center",
          //   customRender: function (t, r, index) {
          //     return parseInt(index) + 1;
          //   }
          // },
          {
            title: '品类',
            align: "center",
            dataIndex: 'parentName',
            width: 120,
            sorter: true
          },
          {
            title: '业务类型',
            align: "center",
            width: 80,
            dataIndex: 'businessType',
            sorter: true,
            customRender: (businessType) => {
              //字典值替换通用方法
              if(businessType==0)
              return "个定定制";
              else  if(businessType==1)
              return "团体定制";
              else
              return "标码加工";
            }
          },
          {
            title: '工艺类型',
            align: "center",
            width: 100,
            dataIndex: 'categoryName'
          },
          {
            title: '新增时间',
            align: "center",
            width: 100,
            dataIndex: 'createTime'
          },
          {
            title: '状态',
            align: "center",
            width: 100,
            dataIndex: 'status',
                   customRender: (status) => {
              //字典值替换通用方法
              if(status==0)
              return "未设置";
              else  if(status==1)
              return "已设置";
            }
          },
     {
            title: '设置售价',
            dataIndex: 'action',
              width: 100,
            align: "center",
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'},
          }
        ],
        url: {
          list: "/PriceManagementController/list",
           pingleilist:"/Discount/getallcategory"
        },
      }
    },
    computed: {
      /*importExcelUrl: function () {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }*/
    },
    created() {
        this.getallcategory();
    },
    methods: {
      //查询所有品类
          getallcategory(){
           getAction(this.url.pingleilist).then((res)=>{
              if(res.success){
               this.categoryList=res.result;
              }else{
                this.$message.warning(res.message);
              } })
      },
      seeLadderPriceSetting(record){
          this.$router.push({path:'/LadderPriceSetting',
          query: {parentName:record.parentName,
                  businessType:record.businessType,
                 categoryName:record.categoryName,
                 id:record.id
          }
          })
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>